Skip to content

Add start end position to nodes#9

Merged
jensneuse merged 8 commits intomasterfrom
add-start-end-position-to-nodes
Jan 17, 2019
Merged

Add start end position to nodes#9
jensneuse merged 8 commits intomasterfrom
add-start-end-position-to-nodes

Conversation

@jensneuse
Copy link
Copy Markdown
Member

This PR adds recent changes to the master. See the #8 for details.

@jensneuse jensneuse merged commit bf88dff into master Jan 17, 2019
jensneuse pushed a commit that referenced this pull request Apr 14, 2020
buger added a commit to buger/graphql-go-tools that referenced this pull request Apr 30, 2026
Targeted the highest-leverage hotspots ranked by .proof/mcdc/go/latest.json
decision count × inverse coverage. Added 91 real exercising tests across
three rounds; 1 of them turned up a new defensive-coding bug (Resolvable.Reset
nil-xxh dereference) which is captured as a failing reproducer test.

MC/DC coverage delta:
  statement: 73.32% -> 84.26% (+10.94pts)
  decision:  36.31% -> 52.64% (+16.33pts)
  condition: 38.68% -> 54.04% (+15.36pts)
  fully-covered decisions: 289 -> 419 (+130)

New tests:
  mcdc_aggressive_coverage_test.go     (round 1, 43 tests — Equals/Copy/helpers)
  mcdc_aggressive_round2_test.go       (round 2, 17 tests — Resolver.New defaults,
                                        trigger map !ok branches, FetchTreeNode helpers)
  mcdc_aggressive_round3_test.go       (round 3, 30 tests — errors.go, context.go,
                                        variables_renderer.go, inputtemplate.go branches)
  cve_reproducers_round2_test.go       (1 failing reproducer — Bug wundergraph#9)

New bug (round 2):
  Bug wundergraph#9 — Resolvable.Reset nil-xxh dereference at resolvable.go:109
    Reproducer: TestCVE_BUG009_ResolvableResetNilXxhPanic (failing by design)
    Severity:   CVSS 5.3 Medium (limited reachability — internal pools only)
    See:        docs/cve-candidates.md

Stub witnesses remaining: ~155 (require federation simulator, subgraph HTTP
fixtures, or subscription event-loop wiring) — see mcdc_witnesses_pending_test.go.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 1, 2026
Uses reqproof's proof verify-lemma command (Z3 deeper roadmap, Phase E)
to prove invariants of the resolve package's algorithms.

Lemma 1 (slice_append_length_invariant) PROVES cleanly via Z3's seq
theory — sanity check that the verifier works.

Lemmas 2-4 produce COUNTEREXAMPLES that map to the existing known bugs
(wundergraph#6 FieldInfo.Merge slice parity, wundergraph#7 Field.Copy ParentOnTypeNames,
wundergraph#9 Resolvable.Reset state clearing). These are spec-level evidence
complementing the failing-test reproducers in cve_reproducers_test.go.

Lemma 5 (type_names_pop_safety) PROVES with explicit precondition,
demonstrating the value of // reqproof:requires for documenting safety
invariants the production skipFieldOnTypeNames currently lacks.

The _proof.go file is build-tag-gated (//go:build reqproof_proof) so
production builds exclude the proof code.

Lemmas 2-4 use simplified models because the gosmt translator (Phase
B/C of the SMT roadmap) accepts only a restricted Go subset: pure free
functions, no methods, no for/range loops, no inter-function calls.
The production Field.Copy / FieldInfo.Merge / Resolvable.Reset all use
unsupported constructs, so each lemma inlines a faithful model of the
relevant fragment in its body. The mapping is documented at the top of
resolve_proof.go and per-lemma in docs/cve-candidates.md.

See docs/cve-candidates.md 'Z3-verified lemma evidence (Phase F)' for
per-lemma counterexamples, source-line mapping, and an honest
assessment of what works end-to-end vs. what needed simplification.
buger added a commit to buger/graphql-go-tools that referenced this pull request May 1, 2026
Expands the Z3-verified lemma corpus from 5 (Phase F) to 25 covering
every major obligation class in v2/pkg/engine/resolve — resolvable.go,
node_object.go, loader.go, subscription_filter.go, tainted_objects.go.

Verdict summary:
  - PROVED: 20 (9 via library citations from Phases J/L)
  - COUNTEREXAMPLE: 3 (each reconfirms a known bug at spec level:
      Bug wundergraph#6 FieldInfo.Merge slice-parity desync,
      Bug wundergraph#7 Field.Copy omits ParentOnTypeNames,
      Bug wundergraph#9 Resolvable.Reset stale currentFieldInfo / marshalBuf)
  - UNKNOWN: 2 (recursive-datatype goals; Z3 reports
      "datatype is not well-founded" — cvc5 with --quant-ind is the
      upstream resolution; dispatcher has cvc5 wired in but the
      auto-route heuristic missed both queries)
  - TRANSLATION_ERROR: 0 (after two iterations to fit gosmt subset)

Total wall time: ~114 ms across 25 lemmas (~4.6 ms mean per lemma).
Library citations don't materially shorten Z3 wall time at this scale;
their value is proof auditability — `by(SliceAppendLength)` makes the
load-bearing axiom explicit.

Phase K demonstrates the full Z3 deeper roadmap (reqproof Phases A
through L plus H) cooperating end-to-end on a real commercial Go
codebase. Every Phase contributed: A/B/C (gosmt translator) emit the
SMT, D/E (annotation scanner + orchestrator) dispatch each lemma,
F seed corpus expanded, G cvc5 wired (cited as resolution for
UNKNOWNs), H `by induction(t)` expands the recursive walker lemma,
I auto-synthesises 2 obligations from declarative `// reqproof:invariant`
annotations, J library lemmas cited 9 times via `by(...)`, L
composes the by/induction syntax through the parser.

The remaining gap surfaced by Phase K — and the load-bearing item for
the next round of investment — is recursive-ADT routing: any query
containing `(declare-datatypes ((T 0)) ...)` with a self-referential
field should auto-route to cvc5 by default.

No new bugs surfaced; the corpus reconfirms known structural bugs at
the specification level (rather than in observed runtime test runs)
which is the honest outcome of an incremental verification round.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 3, 2026
Replace v2/pkg/engine/resolve/resolve_proof.go (//go:build reqproof_proof
shadow file) with resolve_lemmas.go, an ordinary production-code file
hosting 25 // reqproof:lemma directives on lemma_* helper functions.

The three former shadow types (ProofResolvable / ProofField /
ProofTypeFieldSource) are gone. Their three lemmas now reference the
production types (Resolvable / Field / TypeFieldSource) via
// reqproof:model directives attached directly on those declarations
in resolvable.go and node_object.go. The model projects the load-bearing
fields:

  Resolvable: wroteData / wroteErrors / currentFieldInfo
  Field:      OnTypeNames / ParentOnTypeNames as []int opaque tags
  TypeFieldSource: IDs / Names

Verdicts preserved: 22 PROVED + 3 COUNTEREXAMPLE (Bugs wundergraph#6, wundergraph#7, wundergraph#9) +
0 UNKNOWN — same as the pre-migration baseline.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 3, 2026
…overage gaps

- v2/pkg/engine/resolve/: was 22 PROVED + 3 CE, parent unchanged at 22 PROVED + 3 CE.
- v2/pkg/engine/resolve/resolveloops/: new sub-package with 11 PROVED loop-invariant
  lemmas (8 Phase S.2c.1 range-over-slice + 3 Phase S.2c.4 break). Sub-package
  needed because the parent's recursive ADT (ProofWalkerNode) clashes with the
  loop-helper translator (snoc-ProofWalkerNode_Children_List undeclared).
- Phase U adoption: 9 -> 15 by() references (+6) — SliceLengthNonNegative,
  MinLEMax, ClampWithinBounds, AddIdentityZero (x3) cited on existing proves-
  syntax lemmas.
- Coverage: 89 branches recorded, 89 covered (100%).
- Documented at docs/reqproof-coverage-gaps.md (G1-G6 phase blockers).
- Pre-existing 3 CEs (BUG-wundergraph#6/wundergraph#7/wundergraph#9) preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 3, 2026
Tautology pruning (operationreportprobes/, 4 deletions):
  - RR-2 reset_clears_lengths: model returned 0 unconditionally; lemma
    asserted post == 0. Z3 saw 0 == 0.
  - RR-3 locations_from_position_length_match: model was identity
    (return positionLen); lemma asserted out == positionLen. Tautology.
  - RR-6 status_code_replacement_envelope: under preconditions the
    model deterministically returned true. Tautology in disguise.
  - RR-7 add_error_grows_length_by_one: model + lemma both
    preLen + 1 == preLen + 1. Hard tautology.

  None were traced to any SYS-REQ — pure speculative bug-hunt fixtures
  with no real falsifiable property. Real Report.Reset / append /
  envelope checking would need slice-mutation translation, a
  translator-phase task.

resolveloops/ removal (Part B, 11 deletions):
  All 11 lemmas asserted `count >= 0` over a counter initialized to 0
  and only ever incremented or held — tautologies-in-disguise. The
  package was carried as a translator-test workaround for a long-fixed
  G1 collision. Nothing migrates inline because nothing earned its
  place there.

Probe-package documentation (Part C):
  README.md added to safetyprobes/, operationreportprobes/, and
  astparserprobes/ explaining the synthetic-probe nature, the
  method-receiver MCDC translator wall, and the Phase SS Path A
  removal plan. File-level doc-comment headers strengthened to point
  at the real production code being mirrored.

Audit at 0/0:
  - documentation_coverage 100% (regenerated SRS picks up RR-block
    requirements).
  - suspect_clean 0 (proof trace review --all after annotation moves).
  - authored_delta_expected 0 (proof review impact for traced files).
  - lint_clean 0 (Implements: SYS-REQ-NNN annotations on all 25
    inline lemma helpers in resolve.go; MarshalJSON tagged
    SYS-REQ-015; lint excludes for autogenerated zz_reqproof_*.go and
    probe packages).

Final corpus state under --no-cache: 75 lemmas total — 66 PROVED,
6 CE (expected), 2 TIMEOUT, 1 UNKNOWN. The 3 non-decisive verdicts
(resolvable_reset_clears_walker_state, fieldinfo_merge_preserves_slice_parity,
field_copy_preserves_parent_on_type_names) are pre-existing real
bug-shape probes (BUG wundergraph#6, wundergraph#7, wundergraph#9) blocked on translator-phase
struct-projection / len(append) / nil-pointer encoding gaps. They are
NOT tautologies — keeping them as honest TIMEOUT/UNKNOWN preserves
spec-level capture; cve_reproducers_test.go provides independent
runtime evidence.

Decision log: reqforge:docs/internal/phase-rr-honest-decision-log.md.

PR #1 reflects the cleanup. RBRACE bug (SYS-REQ-181) stays prominent
with formalization_status: violated and the live Z3 CE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 3, 2026
…iolated

Reqproof Phase TT.1.A (lemma-scoped preamble assembly) made three
previously TIMEOUT/UNKNOWN lemmas resolve in single-digit milliseconds,
producing definitive Z3 counterexamples for all three:

  resolvable_reset_clears_walker_state — Bug wundergraph#9 (Reset() does not
    clear currentFieldInfo). Pre-TT.1.A: TIMEOUT 30s. Post: CE 6ms.
  fieldinfo_merge_preserves_slice_parity — Bug wundergraph#6 (FieldInfo.Merge
    appends to IDs without Names). Pre: UNKNOWN. Post: CE 7ms.
  field_copy_preserves_parent_on_type_names — Bug wundergraph#7 (Field.Copy
    struct literal omits ParentOnTypeNames). Pre: TIMEOUT 30s. Post: CE 7ms.

The corresponding requirements migrate from formalization_status:
valid (which was a misleading no-evidence default — the lemmas were
never resolving) to formalization_status: violated, following the
SYS-REQ-181 known-violation pattern. The Z3 CEs now provide
definitive evidence against the property.

Trace re-review timestamps re-stamped across the spec set per the
standard project workflow when artifact-fingerprint propagation
invalidates stale review records.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 4, 2026
…ace, clean MC/DC artifacts

- proof.yaml: instrument_in_place: false to prevent Phase R architecture violation
  (MC/DC instrumentation was polluting 22 source files with __reqproofMCDC* code)
- Deleted gitignored zz_reqproof_mcdc_runtime.go (MC/DC runtime sidecar artifact)
- Verified: 59 PROVED + 8 CE = 67 lemmas, 0 tautology findings, 100% coverage
- All 7 bug-finding CE-target lemmas confirmed CE under per-lemma scoping (TT.4)
- All 5 CVE reproducer tests confirm bugs (BUG wundergraph#4, wundergraph#5, wundergraph#8, wundergraph#9, wundergraph#10)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 4, 2026
Deleted ~22 synthetic-helper lemmas that were tautologies or by-citation
stdlib restatements (SliceLengthNonNegative, AddIdentityZero, SliceAppendLength,
AddCommutative, etc.) from resolve.go. These proved nothing about real production
code. Kept only the 3 bug-finding COUNTEREXAMPLE lemmas (BUG wundergraph#6, BUG wundergraph#7, BUG wundergraph#9)
that reference production types (TypeFieldSource, Field, Resolvable).

Added 5 new genuine inline lemmas on real production methods in resolvable.go:
  - enclosing_type_name_safe_index (PROVES) + unguarded (CE) on enclosingTypeName()
  - pop_array_path_element_unguarded (CE) on popArrayPathElement()
  - pop_node_path_element_unguarded (CE) on popNodePathElement()
  - write_array_element_path_unguarded (CE) on writeArrayElementToBuffer()
  - non_nullable_error_path_guarded (PROVES) on renderApolloCompatibleNonNullableErrorMessage()

Corpus: 39 -> 17 total (7 PROVED, 10 CE). All 6 original bug-finding CEs intact.
Audit: 0 failing verification steps.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 4, 2026
…, fragility probe documentation

- Audit all 45 lemmas: 33 PROVED, 12 CE, 0 tautologies, 0 SYS-REQ mismatches
- Classified 4 UU.14 CEs as fragility probes (load-bearing-precondition probes)
- Added UU.19 annotations to 3 synthetic-wrapper CEs (BUG wundergraph#6, wundergraph#7, wundergraph#9)
- All 7 bug-tracking SYS-REQs confirmed as `violated`
- No new SYS-REQs needed
- verify-lemma: 45/45 pass; CVE tests: 5/5 pass

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 6, 2026
… public API

Three bugs now confirmed through public API calls:
- RBRACE: leading extra brace bypasses MaxDepth limit via TokenizeWithLimits
- BUG wundergraph#4: ParentOnTypeNames Depth=1 at root panics via ResolveGraphQLResponse
- BUG wundergraph#9: Reset() leaves currentFieldInfo stale pointer via Reset() on Resolvable

Three bugs documented as unreachable via query string (pure internal invariants):
- BUG wundergraph#5: skipFieldOnTypeNames empty-stack path unreachable through walkObject
- BUG wundergraph#6: fieldinfo merge slice parity is planner-side data structure invariant
- BUG wundergraph#7: field copy omission is data structure correctness defect

BUG wundergraph#8: existing executeSubscriptionUpdate coverage adequate for disclosure

Adds cve_graphql_queries_test.go with public-API CVE reproducers. Updates all
7 disclosure documents with query strings and reachability analysis.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 6, 2026
Classifies each of 7 bugs as Exploitable/Triggerable via API/Internal
based on call-path tracing from public API entry points used by
WunderGraph's Cosmo Router.

Key findings:
- RBRACE: Exploitable — } prefix bypasses MaxDepth entirely
- BUG wundergraph#8: Exploitable — subscription nil-deref when AsyncErrorWriter unset
- BUG wundergraph#9: Triggerable via API — currentFieldInfo leaks across pooled Resolvable reuse
- BUG wundergraph#4/wundergraph#5/wundergraph#6/wundergraph#7: Internal — not reachable via real HTTP requests

Deliverables:
- exploitability-matrix.md with per-bug classification and Cosmo Router impact
- Updated disclosure docs with Exploitability sections
- End-to-end exploitability demonstration tests
- Decision log in reqforge worktree

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
buger added a commit to buger/graphql-go-tools that referenced this pull request May 6, 2026
Re-analyzed all 7 graphql-go-tools bugs as if receiving a disclosure report:

- Added UU.48 observability test for BUG wundergraph#9 confirming stale currentFieldInfo
  is NOT observable in current code (latent time bomb, not CVSS 5.3)
- Added dead-code confirmation tests for BUG wundergraph#6 (FieldInfo.Merge) and
  BUG wundergraph#7 (Field.Copy) — neither method has production callers
- Rewrote severity table with three tiers: Exploitable (BUG wundergraph#8, RBRACE),
  Defensive (BUG wundergraph#4, BUG wundergraph#5, BUG wundergraph#9), and Code Quality (BUG wundergraph#6, BUG wundergraph#7)
- Updated CVSS: BUG wundergraph#4/wundergraph#5 from 7.5 to N/A, BUG wundergraph#9 from 5.3 to N/A (latent)
- Created executive summary disclosure from WunderGraph engineer perspective
- Created decision log for UU.48 findings
- Updated all 7 individual bug disclosure docs with refined framing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant